import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import vueDevTools from 'vite-plugin-vue-devtools'
import qiankun from 'vite-plugin-qiankun';

// https://vite.dev/config/
export default defineConfig({
  base: 'http://172.20.10.5:5555/',
  server: {
    host: '172.20.10.5', // 例如 '192.158.1.100' ，若想监听所有IPv4地址，可写 '0.0.0.0'
    port: 5555,//端口
    cors: true,
    origin: 'http://172.20.10.5:5555',
    },
    plugins: [
      vue(),
      qiankun('staff', { // 必须与子应用注册名称一致
        useDevMode: true
      })
    ],
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url))
      },
    },
    build: {
      rollupOptions: {
        output: {
          format: 'umd',
          name: 'staff', // 与 window.ReactApp 一致!!!!!!!!!
          entryFileNames: '[name].umd.js',
        },
      },
    },
  })